package com.tinem.platform.web.auth;

import com.alibaba.fastjson.JSONObject;
import com.baidu.fsg.uid.annotation.EnableCacheUid;
import com.tinem.platform.module.starter.jpa.annotation.EnableJpa;
import com.tinem.platform.module.starter.web.annotation.EnableWeb;
import com.tinem.platform.module.starter.web.config.FeignConfiguration;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ApplicationContext;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;

/**
 * @author fengzhihao
 * @version v1
 * @program: platform
 * @className AuthApplication
 * @description localhost:38667/oauth/authorize?client_id=client&response_type=code&redirect_uri=http://www.baidu.com
 * @site 
 * @company 
 * @create 2020-06-18 14:44
 */
@Slf4j
@EnableWeb
@EnableJpa
@EnableCacheUid
@EnableWebSecurity
@SpringBootApplication
@EnableDiscoveryClient
@EnableGlobalMethodSecurity(securedEnabled = true,prePostEnabled = true)
@EnableFeignClients(value = {"com.tinem.platform.client.network","com.tinem.platform.client.security"},defaultConfiguration = FeignConfiguration.class)
public class AuthWebApplication {
    public static ApplicationContext applicationContext;
    public static void main(String[] args) {
        long startTime = System.currentTimeMillis();

        applicationContext = SpringApplication.run(AuthWebApplication.class, args);
        System.out.println(JSONObject.toJSONString(AuthWebApplication.applicationContext.getBeanNamesForType(ResourceServerTokenServices.class),true));

        long endTime = System.currentTimeMillis();
        System.out.println("start success; duration:("+ (endTime - startTime) +");startTime:("+startTime+");endTime:("+ endTime +")");
        log.info("start success; duration:({});startTime:({});endTime:({})",(endTime - startTime),startTime,endTime);


    }
}
